﻿using MailDAL;
using MailTool.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MailTool.Pages
{
    public partial class TemplateView : System.Web.UI.Page
    {
        UnitOfWork unitOfWork = new UnitOfWork();

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected Dictionary<string, string> GetActivityContent
        {
            get
            {
                Dictionary<string, string> result = ContentDetail;
                if (result == null)
                {
                    result = new Dictionary<string, string>();
                    MailModel.Template info = unitOfWork.TemplateRepository.Get(p => p.Id == TemplateID, null, 1, 0, x => x.User).FirstOrDefault();
                    result.Add("TemplateName", info.TemplateName);
                    result.Add("TemplateTitle", info.TemplateTitle);
                    result.Add("TemplateContent", Server.HtmlDecode(info.TemplateContent));
                    result.Add("UserName", info.User.UserName);
                    result.Add("CreateDate", info.CreateDate.ToString("yyyy-MM-dd"));
                    result.Add("UpdateDate", info.UpdateDate.ToString("yyyy-MM-dd"));
                    ContentDetail = result;
                }
                else
                {
                    //页面不存在
                }
                return result;
            }
        }

        protected int TemplateID
        {
            get
            {
                return Convert.ToInt32(base.Request["templateId"]);
            }
        }

        protected Dictionary<string, string> ContentDetail
        {
            get
            {
                return (this.ViewState["contentDetail"] as Dictionary<string, string>);
            }
            set
            {
                this.ViewState["contentDetail"] = value;
            }
        }
    }
}